﻿#pragma once

#ifndef QCEFBROWSERAPP_H
#define QCEFBROWSERAPP_H

#include "QCefDebug.h"
#include "QCefApp.h"
#include "QCefBrowserProcessHandler.h"
#include "QCefRenderProcessHandler.h"

class QCefBrowserApp 
    : public QCefApp
    , public QCefBrowserProcessHandler 
#ifdef QT_CEF_SINGLE_PROCESS
    , public QCefRenderProcessHandler
#endif  //QT_CEF_SINGLE_PROCESS
{
public:
    inline static QCefBrowserApp * instance() { return ms_instance; }

protected:
    static QCefBrowserApp * ms_instance;         //

public:
    QCefBrowserApp();
    virtual ~QCefBrowserApp();

public:
    //////////////////////////////////////////////////////////////////////////
    //CefApp
    virtual void OnBeforeCommandLineProcessing(const CefString& process_type,
                                               CefRefPtr<CefCommandLine> command_line) override;

    virtual CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() override;

    virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler() override;

private:    
    IMPLEMENT_REFCOUNTING(QCefBrowserApp);
    DISALLOW_COPY_AND_ASSIGN(QCefBrowserApp);
};

#endif  // QCEFBROWSERAPP_H
